<script type="text/html" template lay-done="layui.data.sendParams(d);">
    <div class="layui-form coreshop-form layui-form-pane" lay-filter="LAY-app-designer-editForm" id="LAY-app-designer-editForm">
	    <input type="hidden" name="id"  value="{{d.params.data.id || '' }}" />
	    <div class="layui-form-item">
            <label for="id" class="layui-form-label  layui-form-required layui-hide">ID</label>
            <div class="layui-input-block layui-hide">
                <input  type="number" min="0" max="999999" name="id"   lay-verType="tips" lay-verify="required|number" class="layui-input" value="{{d.params.data.id || '' }}" placeholder="请输入ID" lay-reqText="请输入ID并为数字"  />
            </div>
        </div>
	    
	    <div class="layui-form-item">
            <label for="name" class="layui-form-label  layui-form-required">名称</label>
            <div class="layui-input-block">
                <input name="name"   lay-verType="tips" lay-verify="required" class="layui-input" placeholder="请输入名称" lay-reqText="请输入名称"  value="{{d.params.data.name || '' }}" />
            </div>
        </div>
	    
	    <div class="layui-form-item">
            <label for="imageUrl" class="layui-form-label  layui-form-required">LOGO</label>
            <div class="layui-input-inline">
                <input name="imageUrl" id="imageUrlInput" lay-verType="tips" lay-verify="required" class="layui-input"  value="{{d.params.data.imageUrl || '' }}" placeholder="请上传LOGO" lay-reqText="请上传LOGO"  />
            </div>
		    <div class="layui-input-inline">
                <img class="coreshop-upload-img" id="viewImgBoximageUrl" src="{{d.params.data.imageUrl || layui.setter.noImagePicUrl }}">
                <button type="button" class="layui-btn" id="upBtnimageUrl" lay-active="doCropperImg">上传图片</button>
            </div>
        </div>
	    
	    <div class="layui-form-item">
            <label for="sort" class="layui-form-label  layui-form-required">排序</label>
            <div class="layui-input-block">
                <input  type="number" min="0" max="999999" name="sort"   lay-verType="tips" lay-verify="required|number" class="layui-input" value="{{d.params.data.sort || '' }}" placeholder="请输入排序" lay-reqText="请输入排序并为数字"  />
            </div>
        </div>
	    
	    <div class="layui-form-item" pane>
            <label for="isShow" class="layui-form-label  layui-form-required">是否显示</label>
            <div class="layui-input-block">
                <input type="checkbox" lay-filter="switch" name="isShow"   {{ d.params.data.isShow ? 'checked' : '' }} lay-skin="switch" lay-text="开启|关闭">
            </div>
        </div>
	    
	    <div class="layui-form-item layui-hide">
            <label for="createTime" class="layui-form-label  layui-form-required ">更新时间</label>
            <div class="layui-input-block">
                <input name="createTime"  id="editTime-designer-createTime" type="text" lay-verType="tips" class="layui-input" placeholder="请输入更新时间"    value="{{d.params.data.createTime || '' }}"/>
            </div>
        </div>
	    
	    <div class="layui-form-item">
            <label for="describe" class="layui-form-label  layui-form-required">描述</label>
            <div class="layui-input-block">
                <input name="describe"   lay-verType="tips" lay-verify="required" class="layui-input" placeholder="请输入描述" lay-reqText="请输入描述"  value="{{d.params.data.describe || '' }}" />
            </div>
        </div>
	    
        <div class="layui-form-item text-right core-hidden">
            <input type="button" class="layui-btn" lay-submit lay-filter="LAY-app-designer-editForm-submit" id="LAY-app-designer-editForm-submit" value="确认编辑">
        </div>
    </div>
</script>
<script>
    var debug= layui.setter.debug;
    layui.data.sendParams = function (d) {
        //开启调试情况下获取接口赋值数据
        if (debug) { console.log(d.params.data); }
        layui.use(['admin', 'form', 'laydate', 'upload', 'coreHelper', 'cropperImg'],
        function () {
            var $ = layui.$
                , form = layui.form
                , admin = layui.admin
                , laydate = layui.laydate
                , upload = layui.upload
                , cropperImg = layui.cropperImg
                , coreHelper = layui.coreHelper;
        
            //LOGO图片裁剪上传
            $('#upBtnimageUrl').click(function () {
                cropperImg.cropImg({
                    aspectRatio: 1 / 1,
                    imgSrc: $('#viewImgBoximageUrl').attr('src'),
                    onCrop: function (data) {
                        var loadIndex = layer.load(2);
                        coreHelper.Post("api/Tools/UploadFilesFByBase64", { base64: data }, function (res) {
                            if (0 === res.code) {
                                $('#viewImgBoximageUrl').attr('src', res.data.fileUrl);
                                $("#imageUrlInput").val(res.data.fileUrl);
                                layer.msg(res.msg);
                                layer.close(loadIndex);
                            } else {
                                layer.close(loadIndex);
                                layer.msg(res.msg, { icon: 2, anim: 6 });
                            }
                        });
                    }
                });
            });
            
            laydate.render({
                elem: '#editTime-designer-createTime',
                type: 'datetime'
            });
            form.verify({
                
            });
            //重载form
            form.render(null, 'LAY-app-designer-editForm');
        })
    };
</script>
